Skip to content

fix(id/web): encode xterm modifiers for special keys in world keyboard encoder (#732) - #3184

Merged
dezren39 merged 1 commit into
mainfrom
queue/4622-732-world-keyboard-modifiers
Oct 31, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4622-732-world-keyboard-modifiers

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #732 — implements the Option 1 decision recorded on the issue (queue task 4622; triage task 1074 CONFIRMED the matrix on main).

Policy (one rule for every special key × modifier)

terminalBytesForKey in pkgs/id/web/src/world-keyboard.ts no longer drops or silently degrades modified special keys:

  • CSI keys carry the standard xterm modifier parameter (1 + Shift·1 + Alt·2 + Ctrl·4): tilde keys as CSI <code>;<mod>~ (Ctrl+Delete = ESC[3;5~, Alt+PageUp = ESC[5;3~), letter keys as CSI 1;<mod><letter> (Alt+Up = ESC[1;3A, Shift+Home/End = ESC[1;2H / ESC[1;2F). Shift+Tab keeps the traditional ESC[Z; Shift+Tab with further modifiers uses CSI 1;<mod>Z.
  • Keys with no CSI form (Backspace, Enter, Escape, Tab without Shift) are ESC-prefixed when modified — the convention this function already used for Alt+printable (Alt+Backspace = ESC DEL). The prefix signals "modified" even though those keys cannot distinguish which modifier was held.
  • No modified special key returns the plain key bytes, and modified arrows no longer return null, so they no longer leak to the browser (Alt+Left/Right history navigation) via the world.ts caller.
  • Unmodified specials, control letters, and AltGr (Ctrl+Alt printable) behaviour are unchanged.

Note on the Roc decoder

pkgs/id/examples/roc-world/Key.roc surfaces the new sequences as Unknown(bytes) today (its pinned test: Key.parse(ESC[1;5C) == [Unknown(ESC[1;5C)]) — preserved, not misreported. Naming modified variants in Key.roc is a later extension and is out of scope here.

Tests

  • New regression tests in world-keyboard.test.ts pin the policy: Ctrl+Delete, Alt+PageUp, Alt+Arrow, Ctrl+ArrowLeft, Shift+Home/End, Shift+Tab (+Ctrl), Alt+Backspace, Alt+Enter, plus a matrix test asserting no (special × modifier) combination returns null or the plain bytes.
  • The one pre-existing expectation that changed: Ctrl+ArrowLeft was expected to be null (browser shortcut); under Option 1 it is ESC[1;5D.
  • Laptop verification: vitest run src/world-keyboard.test.ts — 8/8 pass with the fix; 5 of the new/changed tests fail against the pristine encoder. tsc --noEmit passes.

Queue task 4622, Lane D.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 18:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T18:55:29.415819Z 64e63c0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ac3b0fa-2c2e-4e1e-b89a-9b0103de0e11
Commits

Reviewing files that changed from the base of the PR and between fe62dc7 and 64e63c0.

Files selected for processing: 2
  • pkgs/id/web/src/world-keyboard.test.ts
  • pkgs/id/web/src/world-keyboard.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Review — queue worker, lane E (user/review discharged)

Reviewed PR #3184 @64e63c01d against the Option 1 decision recorded on #732:

  • Policy correctness: xterm modifier parameter 1 + Shift + 2·Alt + 4·Ctrl applied uniformly — CSI tilde keys as CSI <code>;<mod>~ (Ctrl+Delete = ESC[3;5~), CSI letter keys as CSI 1;<mod><letter> (Alt+Up = ESC[1;3A), Shift+Tab keeps plain ESC[Z (further modifiers get CSI 1;<mod>Z), and no-CSI-form keys (Backspace/Enter/Escape/Tab-without-Shift) are ESC-prefixed (Alt+Backspace = ESC DEL). No modified special returns the plain bytes or null.
  • Tests: the new suites pin every acceptance example from the packet plus a full special×modifier matrix (non-null, ≠ plain). First-hand on the laptop at this head: bun test pkgs/id/web/src/world-keyboard.test.ts — 8/8 pass, 214 assertions.
  • Scope: exactly the two in-scope files; unmodified specials, control letters, and AltGr untouched; no Roc or world.ts changes.
  • Codex: no Codex review or inline findings exist on this PR — nothing undispositioned.

Verdict: approved on substance. The only remaining gate is the dispatched id-check run 41231798279 (queued/in-progress in the fleet runner backlog since 18:56Z). Merge when it settles green.

@dezren39
dezren39 merged commit c0fb853 into main Oct 31, 2026
19 of 31 checks passed
@dezren39
dezren39 deleted the queue/4622-732-world-keyboard-modifiers branch October 31, 2026 23:58
@dezren39
dezren39 restored the queue/4622-732-world-keyboard-modifiers branch November 1, 2026 09:15
@dezren39
dezren39 deleted the queue/4622-732-world-keyboard-modifiers branch November 1, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant